<?php
/**
 * Created by PhpStorm.
 * User: Michael Ma
 * Date: 2017/4/14
 * Time: 20:09
 * 注册添加user表
 */

header("Content-Type: text/plain;charset=utf-8");
header("Access-Control-Allow-Origin:*");
header("Access-Control-Methods:POST,GET");

//载入register.php类
require_once ("classes/register.php");
require_once ("classes/user.php");

//接受前台数据
$name = isset($_POST['name']) ? $_POST['name'] : '';                        //用户名
$pic = isset($_POST['pic']) ? $_POST['pic'] : '';                           //用户头像
$psw = isset($_POST['psw']) ? $_POST['psw'] : '';                           //用户密码

echo $name;
echo $pic;
echo $psw;

//实例化register类，调用方法插入类
$insertRegister = new Register();
$result1 = $insertRegister -> insertUser($name,$pic,$psw);

//异常处理
if(!$result1){
    $error = "10";
}else{
    $error = "";
}

echo json_encode($error,JSON_UNESCAPED_UNICODE);

?>
